<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>颜色选择器</title>
    <style>
        body {
            font-family: Arial, sans-serif;
            margin: 20px;
        }
        .color-preview {
            width: 100px;
            height: 100px;
            border: 1px solid #000;
            margin-top: 10px;
        }
    </style>
</head>
<body>
    <h1>颜色选择器</h1>
    <input type="color" id="colorPicker" value="#ff0000">
    <div id="colorPreview" class="color-preview"></div>

    <script>
        const colorPicker = document.getElementById('colorPicker');
        const colorPreview = document.getElementById('colorPreview');

        colorPicker.addEventListener('input', function() {
            colorPreview.style.backgroundColor = colorPicker.value;
        });
    </script>
</body>
</html>